package com.woniuxy.hrp.mapper;


import com.woniuxy.hrp.entity.Reservation;
import com.woniuxy.hrp.entity.Walletopr;
import com.woniuxy.hrp.provider.ReservationSqlProvider;
import com.woniuxy.hrp.provider.WalletoprMapperSqlProvide;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

@Mapper
public interface WalletoprMapper {
    /**
     * desc:添加钱包操作记录
     * 主键返回
     * @Author: caojieke
     * @Date: 2022/8/29 20:04
     */
    @Insert("insert hrp_walletopr (datetime,way,orderId,project,fee,status,wallet_id) values(#{datetime},#{way},#{orderId},#{project},#{fee},#{status},#{wallet.id})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    public void insert(Walletopr walleopr);
    /**
     * desc:查询该患者所有钱包操作记录
     * @Author: caojieke
     * @Date: 2022/8/29 20:03
     */
    @Select("select * from hrp_walletopr where id=#{id}")
    List<Walletopr> getById(int id);

    /**
     * 按条件查询
     * @param walletopr
     * @return
     */
    @SelectProvider(type = WalletoprMapperSqlProvide.class, method = "getByCondition")
    List<Walletopr> selectByCondition(Walletopr walletopr);

    /***
     * @description: 根据患者查询所有支付信息
     * @param: patientId
     * @return: java.util.List<com.woniuxy.hrp.entity.Walletopr>
     * @author Lrw
     * @date: 2022/9/1 1:01
     */
    @Select("select o.* from hrp_wallet w,hrp_walletopr o where w.id=o.wallet_id and patient_id=#{patientId}")
    List<Walletopr> selectByPatientId(int patientId);

    @Insert("insert hrp_walletopr (datetime,way,orderId,project,fee,status,wallet_id) values(#{datetime},#{way},#{orderId},#{project},#{fee},#{status},#{walletid})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    public void add(Walletopr walleopr);
    /***
     * @description: 根据id查记录
     * @param: id
     * @return: com.woniuxy.hrp.entity.Walletopr
     * @author Lrw
     * @date: 2022/9/7 0:00
     */
    @Select("select * from hrp_walletopr where id=#{id}")
    Walletopr selectById(int id);

    /***
     * @description:根据钱包id查所有操作记录
     * @param:
     * @return: java.util.List<com.woniuxy.hrp.entity.Walletopr>
     * @author Lrw
     * @date: 2022/9/7 10:34
     */
    @Select("select * from hrp_walletopr where wallet_id=#{walletId}")
    @Results({
            @Result(column="id",property = "id",id = true),
            @Result(column="wallet_id",property = "wallet.id")})
    List<Walletopr> selectByWalletId(int walletId);

}
